﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;

namespace CrawlerApp.Core.Entities
{
    public class Account: BaseEntity
    {
        public string UserName { get; private set; }
        public string Password { get; private set; }
        public string Email { get; private set; }
        public string Phone { get; private set; }

        private Account() { }
        public Account(string username)
        {
            UserName = username;
        }
        public Account CreateHashPassword(string password)
        {
            using (var md5 = MD5.Create())
            {
                var buffer = Encoding.UTF8.GetBytes(password);
                var hash = md5.ComputeHash(buffer);
                Password = BitConverter.ToString(hash);
            }
            return this;
        }
        public Account SetEmail(string email)
        {
            Email = email;
            return this;
        }
        public Account SetPhone(string phone)
        {
            Phone = phone;
            return this;
        }
    }
}
